package GetMoneyUser;

import java.util.ArrayList;

/**
 * 群主
 */
public class Manager extends User {
    public Manager() {
    }

    public Manager(String name, int money) {
        super(name, money);
    }

    /**
     * 产生一个存储红包的集合
     *
     * @param totalMoney 金额
     * @param count      红包数
     */
    public ArrayList<Integer> send(int totalMoney, int count) {
        ArrayList<Integer> redList = new ArrayList<>();//存储红包
        int leftMoney = super.getMoney();//群主的于额
        if (leftMoney < totalMoney) {
            System.out.println("余额不足");
            return redList;
        }
        //扣掉发的钱数，重新设置余额
        super.setMoney(leftMoney - totalMoney);

        int avg = totalMoney / count;//每个红包的钱数
        for (int i = 0; i < count - 1; i++) {
            redList.add(avg);
        }
        int mode = totalMoney % count;
        int last = avg + mode;
        redList.add(last);
        return redList;
    }
}
